<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改俱乐部')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-club-edit" th:object="${cmsClub}">
            <h4 class="form-header h4">俱乐部信息</h4>
            <input name="clubId" th:field="*{clubId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">俱乐部名称：</label>
                <div class="col-sm-8">
                    <input name="clubName" th:field="*{clubName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">显示顺序：</label>
                <div class="col-sm-8">
                    <input name="orderNum" th:field="*{orderNum}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">负责人：</label>
                <div class="col-sm-8">
                    <input name="leader" th:field="*{leader}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">联系电话：</label>
                <div class="col-sm-8">
                    <input name="phone" th:field="*{phone}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">邮箱：</label>
                <div class="col-sm-8">
                    <input name="email" th:field="*{email}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('club_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">LOGO：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="logoimg" th:field="*{logoimg}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="logoimg" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">地址：</label>
                <div class="col-sm-8">
                    <input name="address" th:field="*{address}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">有无WIFI热点：</label>
                <div class="col-sm-8">
                    <input name="iswifi" th:field="*{iswifi}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">WIFI名称/密码：</label>
                <div class="col-sm-8">
                    <input name="wifi" th:field="*{wifi}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">城市：</label>
                <div class="col-sm-8">
                    <input name="city" th:field="*{city}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">区：</label>
                <div class="col-sm-8">
                    <input name="dist" th:field="*{dist}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">省份：</label>
                <div class="col-sm-8">
                    <input name="prov" th:field="*{prov}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">剑种：</label>
                <div class="col-sm-8">
                    <input name="weapons" th:field="*{weapons}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">总剑道数量：</label>
                <div class="col-sm-8">
                    <input name="StripsQty" th:field="*{StripsQty}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">安装剑道数：</label>
                <div class="col-sm-8">
                    <input name="InstallStripsQty" th:field="*{InstallStripsQty}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">可用状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('club_status')}">
                        <input type="radio" th:id="${'clubstatus_' + dict.dictCode}" name="clubstatus" th:value="${dict.dictValue}" th:field="*{clubstatus}">
                        <label th:for="${'clubstatus_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">场馆面积：</label>
                <div class="col-sm-8">
                    <input name="sitearea" th:field="*{sitearea}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">学员数量：</label>
                <div class="col-sm-8">
                    <input name="traineeQty" th:field="*{traineeQty}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">发布课程数：</label>
                <div class="col-sm-8">
                    <input name="courseQty" th:field="*{courseQty}" class="form-control" type="text">
                </div>
            </div>
            <h4 class="form-header h4">俱乐部场馆照片信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "club/club";
        $("#form-club-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-club-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });

        $(function() {
            var options = {
                data: [[${cmsClub.cmsClubPhotoList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'imgSrc',
                    align: 'center',
                    title: '图片源',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='cmsClubPhotoList[%s].imgSrc' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'imgPath',
                    align: 'center',
                    title: '图片路径',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='cmsClubPhotoList[%s].imgPath' value='%s'>", index, value);
                        return html;
                    }
				
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    imgSrc: "",
                    imgPath: ""
        	    }
            });
        }
    </script>
</body>
</html>